<div class="mod user-card">
  <div class="pic">
    <a href="{{url('space/'~strUser['doname'])}}" target="_blank" title="{{strUser['username']}}"><img src="{{strUser['face_160']}}"></a>
  </div>
  <div class="info">
    <ul>
      <li class="name">{{strUser['username']}}
      </li><li class="loc">
      
      常居:&nbsp;
      {{strUser['area']['areaname']}}
      </li><li class="home-link"><a href="{{url('space/'~strUser['doname'])}}" target="_blank">个人主页</a>
    </li></ul>
  </div>
  {% if visitor['userid'] != strUser['userid'] and visitor %}
  <div class="opt">
      <a class="lnk-doumail" href="{{url('home/message/write/'~strUser['userid'])}}" target="_blank">发消息</a>
      {% if strUser['isfollow'] %}
       <span class="followed">已关注</span>
      {% else %}
       <a class="add_contact" data-id="{{strUser['userid']}}"  href="javascript:;">+&nbsp;关注</a> 
      {% endif %}
  </div>
  {% elseif visitor is empty %}
  
  <div class="opt">
       <a class="lnk-doumail i a_show_login" href="{{url('home/message/write/'~strUser['userid'])}}" target="_blank">发消息</a>
       <a class="add_contact i a_show_login" data-id="{{strUser['userid']}}"  href="javascript:;">+&nbsp;关注</a> 
  </div>
  
  {% endif %}
</div>

<script language="javascript">
$(function(){
	$('.add_contact').bind('click',function(){
		var posturl = '{{url("space/contact/userfollowAjax")}}';
		var self = this, parent = $(self).parent();
		var peopleId = $(this).attr('data-id');
		$.post_withck(
			posturl,
			{ 'userid_follow': peopleId },
			function (result) {
				var obj = $.parseJSON(result);
				if(obj.res==1){
					$(self).remove();
					parent.append('<span class="followed">已关注</span>');			
				}else if(obj.res==0){
					alert(obj.msg)	
				}					
			}
		);
	});	
})
</script>